package com.tcs.service;

import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tcs.dao.RequisitionDao;
import com.tcs.model.Requisition;
import com.tcs.model.RequisitionClose;
import com.tcs.model.RequisitionDetail;
import com.tcs.model.RequisitionState;

@Service("requisitionService")
@Transactional
public class RequisitionServiceImpl implements RequisitionService {

	@Resource
	private RequisitionDao requisitionDao;

	public void addRequisition(Requisition requisition) {
		requisitionDao.saveRequisition(requisition);

	}

	public void addRequisitionDetail(RequisitionDetail requisitionDetail) {
		requisitionDao.saveRequisitionDetail(requisitionDetail);
	}

	public void deleteRequisitionDetail(RequisitionDetail requisitionDetail) {
		requisitionDao.deleteRequisitionDetail(requisitionDetail);
	}

	public void deleteRequisitionDetail(int id) {
		requisitionDao.deleteRequisitionDetail(id);
	}

	public void addRequisitionClose(RequisitionClose requisitionClose) {
		requisitionDao.saveRequisitionClose(requisitionClose);
	}

	public List<Requisition> listRequisitionClose() {

		return requisitionDao.listRequisitionsClose();
	}

	public Requisition getRequisition(int ID) {

		return requisitionDao.getRequisition(ID);
	}

	public RequisitionDetail getRequisitionDetail(int ID) {

		return requisitionDao.getRequisitionDetail(ID);
	}

	@Override
	public List<RequisitionDetail> listRequisitionDetailByReq(int ID) {
		// TODO Auto-generated method stub
		return requisitionDao.listRequisitionDetailByReq(ID);
	}

	@Override
	public List<RequisitionClose> listRequisitionDetailCloseByReq(int ID) {

		return requisitionDao.listRequisitionDetailCloseByReq(ID);
	}

	public List<Requisition> listRequisitionByUser(int ID) {
		return requisitionDao.listRequisitionByUser(ID);
	}

	public List<Requisition> listofRequisitionbyDate(long sinceDate, long toDate) {
		return requisitionDao.listofRequisitionbyDate(sinceDate, toDate);
	}

	@Override
	public RequisitionState getState(int ID) {

		return requisitionDao.getState(ID);
	}

	@Override
	public RequisitionState setState(int ID) {

		return requisitionDao.setState(ID);
	}

	public List<Requisition> listRequisitionByUserByState(int state, int id) {
		return requisitionDao.listRequisitionByUserByState(state, id);
	}

	public List<RequisitionClose> getListRequisitionClose() {
		return requisitionDao.getListRequisitionClose();
	}


	public List<Object[]> listRequisitionOpen() {

		return requisitionDao.listRequisitionOpen();
	}
}
